package com.ht.medicaltreatment.view

import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.graphics.Bitmap
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.databinding.DataBindingUtil
import com.blankj.utilcode.util.ActivityUtils
import com.blankj.utilcode.util.AdaptScreenUtils
import com.blankj.utilcode.util.ConvertUtils
import com.blankj.utilcode.util.ScreenUtils
import com.gym.baselib.utils.CacheUtils
import com.ht.medicaltreatment.R

abstract class BaseDialog(context: Context,width:Float = 300f,height:Float = 0f) : Dialog(context, R.style.dialogStyle) {
    init {
        val view =
            LayoutInflater.from(context).inflate(getLayoutRes(), null, false)
        setContentView(view)
        val attributes = window!!.attributes
        attributes.height = if(height == 0f) ViewGroup.LayoutParams.WRAP_CONTENT else height.toInt()
        attributes.width= if(width == 0f) ViewGroup.LayoutParams.MATCH_PARENT else ConvertUtils.dp2px(width)
        window!!.attributes = attributes
        setCancelable(true)
    }

    @LayoutRes
    abstract fun getLayoutRes():Int

}